//============================================================================
// Name        : problem225.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	long int a, b, c, next;
	int counter = 0;
	for(int i = 27; i < 100000; i += 2) {
		a = 1, b = 1, c = 1;
		while(1) {
			next = a + b + c;
			a = b;
			b = c;
			c = next%i;
			if (c == 0) {
				break;
			}
			if (a == 1 && b == 1 && c == 1) break;
		}
		if (c != 0) {
			counter++;
			if (counter == 124) {
				cout<<i;
				break;
			}
		}
	}
	return 0;
}
